//
//  CSBaseViewController.m
//  JiFengDaRen
//
//  Created by CYF on 2017/3/15.
//  Copyright © 2017年 SH_iOS. All rights reserved.
//
#import "CSBakButton.h"
#import "CSBaseViewController.h"

@interface CSBaseViewController ()

@end

@implementation CSBaseViewController

- (BOOL)shouldAutorotate{
    return YES;
}

-(UIInterfaceOrientationMask)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDefault;
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];


}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = KBASEBGCOLOR;
    [self createNavigationBar];
    self.navigationController.navigationBarHidden = YES;

    // Do any additional setup after loading the view.
}

-(void)createNavigationBar{
    [UINavigationBar appearance].translucent = NO;
    self.csTopView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KNAVIGATIONBARHEIGHT)];
    [self.view addSubview:self.csTopView];
    self.statusBar = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 20)];
    self.statusBar.image = [UIImage imageNamed:@"cs_navigationbar"];
    //.backgroundColor = KCSNAVIGATIONBARCOLOR;
    [self.csTopView addSubview:self.statusBar];
    self.navigationBar = [[UIImageView alloc]initWithFrame:CGRectMake(0, 20,KScreenWidth, 44)];
    self.navigationBar.userInteractionEnabled = YES;
    self.navigationBar.image = [UIImage imageNamed:@"cs_navigationbar@2x"];
    //self.navigationBar.backgroundColor = KCSNAVIGATIONBARCOLOR;
    [self.csTopView addSubview:self.navigationBar];
    
    self.tilteLabel = [[UILabel alloc]init];
    self.tilteLabel.text = @"";
    self.tilteLabel.textAlignment = NSTextAlignmentCenter;
    self.tilteLabel.textColor = [UIColor blackColor];
    self.tilteLabel.font = KSystemFont(__I6Width(18));
    [self.navigationBar addSubview:self.tilteLabel];
    [self.tilteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.navigationBar.mas_centerX);
        make.centerY.equalTo(self.navigationBar.mas_centerY);
        make.height.mas_equalTo(__I6Width(18));
        make.width.mas_equalTo(__I6Width(120));
        
        
    }];
    
    
    self.back = [CSBakButton buttonWithType:UIButtonTypeCustom];
    [self.back setImage:[UIImage imageNamed:@"csback@2x"] forState:UIControlStateNormal];
//    [back setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
    [self.back addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.navigationBar addSubview:self.back];
   
    [self.back mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.navigationBar.mas_left).with.offset(__I6Width(0));
        make.centerY.equalTo(self.navigationBar.mas_centerY);
        make.height.mas_equalTo(44);
        make.width.mas_equalTo(44);
        
        
    }];
    
    
   
}

- (void)backAction:(UIButton *)btn{
    
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)setNavTitle:(NSString *)navTitle{
    
    self.tilteLabel.text = navTitle;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
